Orleans的GrainService是不同於Actor model運算模式的特殊System daemon,它可以用來在每個Silo提供類似系統服務的常駐程式。
IGrainService 介面,而非原本Grain的那五種: IGrainWithIntegerKey 、 IGrainWithStringKey 、 IGrainWithGuidKey IGrainWithIntegerCompoundKey 、 IGrainWithGuidCompoundKey RPC介面的基礎介面型別。AddGrainService() 擴充方法來註冊GrainService。官方對於GrainService的應用,就是拿來實現Grain Reminder的機制,IReminderService 介面就是繼承自 IGrainService 介面,而 LocalReminderService 就是繼承自 GrainService 類別:
https://github.com/dotnet/orleans/blob/main/src/Orleans.Reminders/ReminderService/LocalReminderService.cs
可使用GrainService來記特定Grain RPC方法呼叫次數,步驟如下: